package com.db.person.controller;

import com.db.person.bean.Dept;
import com.db.person.bean.TrainData;
import com.db.person.service.ITrainDataService;
import com.db.person.util.PageModel;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class TrainDataController {

    @Autowired
    private ITrainDataService trainDataService;

    @RequestMapping("/traindata/list")
    public String toList(PageModel pageModel , Model model, Integer pageIndex){

        PageHelper.startPage(pageModel.getPageIndex(),pageModel.getPageSize());
        List<TrainData> all = trainDataService.getAll();

        PageInfo<TrainData> pageInfo = new PageInfo<>(all);

        List<TrainData> list = pageInfo.getList();

        pageModel.setRecordCount((int)pageInfo.getTotal());

        model.addAttribute("list",list);
        model.addAttribute("pageModel",pageModel);

        model.addAttribute("hre","traindata/list");

        return "traindata/list";
    }

}
